import main
import output
import datetime
import loader

start_date = datetime.datetime(2014, 10, 7, 0, 0)
end_date = datetime.datetime(2014, 10, 9, 0, 0)
#end_date = datetime.datetime(2014, 9, 11, 0, 0)
delta = 1

#[class_data, scan_data_binned] = main.load_data(start_date, end_date)
raw_data = loader.loadScanData(loader.DATA_FOLDER + "//" + loader.WIFI_DATA_FILENAME, start_date, end_date)
scan_data_binned = loader.loadScanDataBinned(loader.DATA_FOLDER + "//" + loader.WIFI_DATA_FILENAME, start_date, end_date, delta)
class_data = loader.loadTransportData(loader.DATA_FOLDER + "//" + loader.CLASS_DATA_FILENAME)

output.plot_figure_scatter(raw_data, class_data, start_date, end_date, "raw_data" + datetime.datetime.strftime(start_date, "%Y-%m-%d") + datetime.datetime.strftime(end_date, "%Y-%m-%d") + ".pdf", (8,4), True, {}, {})
#output.plot_figure_1(raw_data, delta, class_data, start_date, end_date, "binned_" + str(delta)+ datetime.datetime.strftime(start_date, "%Y-%m-%d") + datetime.datetime.strftime(end_date, "%Y-%m-%d") + ".pdf", (4,4), True, {}, {}, True)


#output.plot_figure_1(raw_data, )

# Plot histogram of occurences#################################################
#output.plot_router_histogram(hist_data, 200)

#   
## Plot raw data - scatter plot#################################################
#plot_figure(scan_data_routers_count, min(dates), max(dates), "data_raw_big.pdf", (8,12))
#plot_figure(scan_data_routers_count, min(dates), max(dates), "data_raw_small.pdf", (8,6))
#plot_figure(scan_data_routers_count, min(dates), max(dates), "data_raw_gt_big.pdf", (8,12), True)
#plot_figure(scan_data_routers_count, min(dates), max(dates), "data_raw_gt_small.pdf", (8,6), True)
#
## Plot binned data 1 min - scatter plot########################################
#plot_figure(scan_data_routers_count_1min_bin, min(dates), max(dates), "data_bin_1min_big.pdf", (8,12))
#plot_figure(scan_data_routers_count_1min_bin, min(dates), max(dates), "data_bin_1min_small.pdf", (8,6))
#plot_figure(scan_data_routers_count_1min_bin, min(dates), max(dates), "data_bin_1min_gt_big.pdf", (8,12), True)
#plot_figure(scan_data_routers_count_1min_bin, min(dates), max(dates), "data_bin_1min_gt_small.pdf", (8,6), True)
### Calculate and plot Jaccard-index for 1-min binned data
### just Jaccard
#delta = 1 # min bins
#num = 3 # how many jaccard measurement have to be taken into account of difference
#jaccard_data = calculate_jaccard(scan_data_routers_count_1min_bin, delta)
#jaccard_diff_data = calculate_jaccard_difference(jaccard_data, num)
#plot_jaccard(jaccard_data, delta, min(dates), max(dates), "jaccard_" + str(delta) + "min_bins.pdf")
#plot_jaccard_diff(jaccard_diff_data, delta, min(dates), max(dates), "jaccard_diff_" + str(delta) + "min_bins" + str(num) + ".pdf", True)
#plot_jaccard(jaccard_data, delta, min(dates), max(dates), "jaccard_" + str(delta) + "min_bins_gt.pdf", True)
## Jaccard on scatter plot with GT
#plot_figure(scan_data_routers_count_1min_bin, min(dates), max(dates), "data_bin_1min_gt_small_jaccard.pdf", (8,6), True, jaccard_data)
#
##Plot only most frequent routers 1 min binned##################################
#plot_figure(scan_data_routers_count_1min_bin_frequent, min(dates), max(dates), "data_bin_1min_frequent_big.pdf", (8,12))
#plot_figure(scan_data_routers_count_1min_bin_frequent, min(dates), max(dates), "data_bin_1min_frequent_small.pdf", (8,6))
#plot_figure(scan_data_routers_count_1min_bin_frequent, min(dates), max(dates), "data_bin_1min_frequent_gt_big.pdf", (8,12), True)
#plot_figure(scan_data_routers_count_1min_bin_frequent, min(dates), max(dates), "data_bin_1min_frequent_gt_small.pdf", (8,6), True)
##Calculate and plot Jacccard-index for most frequent routers
#delta = 5 # min bins
#jaccard_data2 = calculate_jaccard(scan_data_routers_count_1min_bin_frequent, delta)
#plot_jaccard(jaccard_data2, delta, min(dates), max(dates), "jaccard_" + str(delta) + "min_bins_frequent.pdf")
#plot_jaccard(jaccard_data2, delta, min(dates), max(dates), "jaccard_" + str(delta) + "min_bins_gt_frequent.pdf", True)
### Jaccard on scatter plot with GT
#plot_figure(scan_data_routers_count_1min_bin_frequent, min(dates), max(dates), "data_bin_1min_gt_small_jaccard_frequent.pdf", (8,6), True, jaccard_data2)

#TODO: Plot only routers occuring in two 5min bins (?)

#TODO: Imputation

#TODO: Plot multi-mode trips

#TODO: Plot single-mode trips

# Building router network
#k_clique = 3
#min_width = 5
#node_colour = plot_router_network(scan_data_routers_count_1min_bin, 'routers_network_k_' + str(k_clique) + 'min_width_' + str(min_width) + '.pdf', k_clique, min_width)
#plot_figure(scan_data_routers_count_1min_bin, min(dates), max(dates), "data_bin_1min_gt_small_k_clique_" + str(k_clique) + 'min_width_' + str(min_width) + '.pdf', (8,6), True, {}, node_colour)

# Louvain method
#node_colour = plot_router_network(scan_data_routers_count_1min_bin, 'routers_network_louvain.pdf', 0)
#plot_figure(scan_data_routers_count_1min_bin, min(dates), max(dates), 'data_bin_1min_gt_small_louvain.pdf', (8,6), True, {}, node_colour)
#node_colour = plot_router_network(scan_data_routers_count_1min_bin_frequent, 'routers_frequent_network_louvain.pdf', 0)
#plot_figure(scan_data_routers_count_1min_bin_frequent, min(dates), max(dates), 'data_bin_1min_frequent_gt_small_louvain.pdf', (8,6), True, {}, node_colour)

#Directed graph of routers
#plot_router_network_directed(scan_data_routers_count_1min_bin, "routers_directed_graph.pdf", class_data)